Optimal. Leaf size=155 \[ \frac {(A b-2 a B) x}{b^3}-\frac {2 a \left (a^2 A b-2 A b^3-2 a^3 B+3 a b^2 B\right ) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{(a-b)^{3/2} b^3 (a+b)^{3/2} d}+\frac {B \sin (c+d x)}{b^2 d}-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.30, antiderivative size = 155, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.161, Rules used = {3067, 3102,
2814, 2738, 211} \begin {gather*} -\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 d \left (a^2-b^2\right ) (a+b \cos (c+d x))}-\frac {2 a \left (-2 a^3 B+a^2 A b+3 a b^2 B-2 A b^3\right ) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{b^3 d (a-b)^{3/2} (a+b)^{3/2}}+\frac {x (A b-2 a B)}{b^3}+\frac {B \sin (c+d x)}{b^2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 2814
Rule 3067
Rule 3102
Rubi steps
\begin {align*} \int \frac {\cos ^2(c+d x) (A+B \cos (c+d x))}{(a+b \cos (c+d x))^2} \, dx &=-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))}+\frac {\int \frac {a b (A b-a B)+\left (a^2-b^2\right ) (A b-a B) \cos (c+d x)+b \left (a^2-b^2\right ) B \cos ^2(c+d x)}{a+b \cos (c+d x)} \, dx}{b^2 \left (a^2-b^2\right )}\\ &=\frac {B \sin (c+d x)}{b^2 d}-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))}+\frac {\int \frac {a b^2 (A b-a B)+b \left (a^2-b^2\right ) (A b-2 a B) \cos (c+d x)}{a+b \cos (c+d x)} \, dx}{b^3 \left (a^2-b^2\right )}\\ &=\frac {(A b-2 a B) x}{b^3}+\frac {B \sin (c+d x)}{b^2 d}-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))}-\frac {\left (a \left (a^2 A b-2 A b^3-2 a^3 B+3 a b^2 B\right )\right ) \int \frac {1}{a+b \cos (c+d x)} \, dx}{b^3 \left (a^2-b^2\right )}\\ &=\frac {(A b-2 a B) x}{b^3}+\frac {B \sin (c+d x)}{b^2 d}-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))}-\frac {\left (2 a \left (a^2 A b-2 A b^3-2 a^3 B+3 a b^2 B\right )\right ) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b^3 \left (a^2-b^2\right ) d}\\ &=\frac {(A b-2 a B) x}{b^3}-\frac {2 a \left (a^2 A b-2 A b^3-2 a^3 B+3 a b^2 B\right ) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{(a-b)^{3/2} b^3 (a+b)^{3/2} d}+\frac {B \sin (c+d x)}{b^2 d}-\frac {a^2 (A b-a B) \sin (c+d x)}{b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.88, size = 147, normalized size = 0.95 \begin {gather*} \frac {(A b-2 a B) (c+d x)+\frac {2 a \left (-a^2 A b+2 A b^3+2 a^3 B-3 a b^2 B\right ) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\left (-a^2+b^2\right )^{3/2}}+b B \sin (c+d x)+\frac {a^2 b (-A b+a B) \sin (c+d x)}{(a-b) (a+b) (a+b \cos (c+d x))}}{b^3 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.34, size = 205, normalized size = 1.32
method | result | size |
derivativedivides | \(\frac {-\frac {2 a \left (\frac {a \left (A b -a B \right ) b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}-b^{2}\right ) \left (a \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+a +b \right )}+\frac {\left (A \,a^{2} b -2 A \,b^{3}-2 a^{3} B +3 B a \,b^{2}\right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{\left (a -b \right ) \left (a +b \right ) \sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b^{3}}+\frac {\frac {2 B b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 \left (A b -2 a B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{3}}}{d}\) | \(205\) |
default | \(\frac {-\frac {2 a \left (\frac {a \left (A b -a B \right ) b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}-b^{2}\right ) \left (a \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+a +b \right )}+\frac {\left (A \,a^{2} b -2 A \,b^{3}-2 a^{3} B +3 B a \,b^{2}\right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{\left (a -b \right ) \left (a +b \right ) \sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b^{3}}+\frac {\frac {2 B b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}+2 \left (A b -2 a B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b^{3}}}{d}\) | \(205\) |
risch | \(\frac {x A}{b^{2}}-\frac {2 x a B}{b^{3}}-\frac {i B \,{\mathrm e}^{i \left (d x +c \right )}}{2 b^{2} d}+\frac {i B \,{\mathrm e}^{-i \left (d x +c \right )}}{2 b^{2} d}+\frac {2 i a^{2} \left (-A b +a B \right ) \left (a \,{\mathrm e}^{i \left (d x +c \right )}+b \right )}{b^{3} \left (a^{2}-b^{2}\right ) d \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+2 a \,{\mathrm e}^{i \left (d x +c \right )}+b \right )}-\frac {a^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{2}}+\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d}+\frac {2 a^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{3}}-\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d b}+\frac {a^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{2}}-\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d}-\frac {2 a^{4} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d \,b^{3}}+\frac {3 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) d b}\) | \(818\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 359 vs.
\(2 (148) = 296\).
time = 0.44, size = 788, normalized size = 5.08 \begin {gather*} \left [-\frac {2 \, {\left (2 \, B a^{5} b - A a^{4} b^{2} - 4 \, B a^{3} b^{3} + 2 \, A a^{2} b^{4} + 2 \, B a b^{5} - A b^{6}\right )} d x \cos \left (d x + c\right ) + 2 \, {\left (2 \, B a^{6} - A a^{5} b - 4 \, B a^{4} b^{2} + 2 \, A a^{3} b^{3} + 2 \, B a^{2} b^{4} - A a b^{5}\right )} d x + {\left (2 \, B a^{5} - A a^{4} b - 3 \, B a^{3} b^{2} + 2 \, A a^{2} b^{3} + {\left (2 \, B a^{4} b - A a^{3} b^{2} - 3 \, B a^{2} b^{3} + 2 \, A a b^{4}\right )} \cos \left (d x + c\right )\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) - 2 \, {\left (2 \, B a^{5} b - A a^{4} b^{2} - 3 \, B a^{3} b^{3} + A a^{2} b^{4} + B a b^{5} + {\left (B a^{4} b^{2} - 2 \, B a^{2} b^{4} + B b^{6}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{2 \, {\left ({\left (a^{4} b^{4} - 2 \, a^{2} b^{6} + b^{8}\right )} d \cos \left (d x + c\right ) + {\left (a^{5} b^{3} - 2 \, a^{3} b^{5} + a b^{7}\right )} d\right )}}, -\frac {{\left (2 \, B a^{5} b - A a^{4} b^{2} - 4 \, B a^{3} b^{3} + 2 \, A a^{2} b^{4} + 2 \, B a b^{5} - A b^{6}\right )} d x \cos \left (d x + c\right ) + {\left (2 \, B a^{6} - A a^{5} b - 4 \, B a^{4} b^{2} + 2 \, A a^{3} b^{3} + 2 \, B a^{2} b^{4} - A a b^{5}\right )} d x - {\left (2 \, B a^{5} - A a^{4} b - 3 \, B a^{3} b^{2} + 2 \, A a^{2} b^{3} + {\left (2 \, B a^{4} b - A a^{3} b^{2} - 3 \, B a^{2} b^{3} + 2 \, A a b^{4}\right )} \cos \left (d x + c\right )\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) - {\left (2 \, B a^{5} b - A a^{4} b^{2} - 3 \, B a^{3} b^{3} + A a^{2} b^{4} + B a b^{5} + {\left (B a^{4} b^{2} - 2 \, B a^{2} b^{4} + B b^{6}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{{\left (a^{4} b^{4} - 2 \, a^{2} b^{6} + b^{8}\right )} d \cos \left (d x + c\right ) + {\left (a^{5} b^{3} - 2 \, a^{3} b^{5} + a b^{7}\right )} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] Timed out
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Timed out} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 1116 vs.
\(2 (148) = 296\).
time = 0.53, size = 1116, normalized size = 7.20 \begin {gather*} \frac {\frac {{\left (4 \, B a^{6} b^{2} - 2 \, A a^{5} b^{3} - 2 \, B a^{5} b^{3} + A a^{4} b^{4} - 9 \, B a^{4} b^{4} + 5 \, A a^{3} b^{5} + 4 \, B a^{3} b^{5} - 2 \, A a^{2} b^{6} + 5 \, B a^{2} b^{6} - 3 \, A a b^{7} - 2 \, B a b^{7} + A b^{8} + 2 \, B a^{3} {\left | -a^{2} b^{3} + b^{5} \right |} - A a^{2} b {\left | -a^{2} b^{3} + b^{5} \right |} - B a^{2} b {\left | -a^{2} b^{3} + b^{5} \right |} + A a b^{2} {\left | -a^{2} b^{3} + b^{5} \right |} - 2 \, B a b^{2} {\left | -a^{2} b^{3} + b^{5} \right |} + A b^{3} {\left | -a^{2} b^{3} + b^{5} \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a^{3} b^{2} - 2 \, a b^{4} + \sqrt {-4 \, {\left (a^{3} b^{2} + a^{2} b^{3} - a b^{4} - b^{5}\right )} {\left (a^{3} b^{2} - a^{2} b^{3} - a b^{4} + b^{5}\right )} + 4 \, {\left (a^{3} b^{2} - a b^{4}\right )}^{2}}}{a^{3} b^{2} - a^{2} b^{3} - a b^{4} + b^{5}}}}\right )\right )}}{a^{3} b^{2} {\left | -a^{2} b^{3} + b^{5} \right |} - a b^{4} {\left | -a^{2} b^{3} + b^{5} \right |} + {\left (a^{2} b^{3} - b^{5}\right )}^{2}} + \frac {{\left ({\left (a^{2} b - a b^{2} - b^{3}\right )} \sqrt {a^{2} - b^{2}} A {\left | -a^{2} b^{3} + b^{5} \right |} {\left | -a + b \right |} - {\left (2 \, a^{3} - a^{2} b - 2 \, a b^{2}\right )} \sqrt {a^{2} - b^{2}} B {\left | -a^{2} b^{3} + b^{5} \right |} {\left | -a + b \right |} - {\left (2 \, a^{5} b^{3} - a^{4} b^{4} - 5 \, a^{3} b^{5} + 2 \, a^{2} b^{6} + 3 \, a b^{7} - b^{8}\right )} \sqrt {a^{2} - b^{2}} A {\left | -a + b \right |} + {\left (4 \, a^{6} b^{2} - 2 \, a^{5} b^{3} - 9 \, a^{4} b^{4} + 4 \, a^{3} b^{5} + 5 \, a^{2} b^{6} - 2 \, a b^{7}\right )} \sqrt {a^{2} - b^{2}} B {\left | -a + b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a^{3} b^{2} - 2 \, a b^{4} - \sqrt {-4 \, {\left (a^{3} b^{2} + a^{2} b^{3} - a b^{4} - b^{5}\right )} {\left (a^{3} b^{2} - a^{2} b^{3} - a b^{4} + b^{5}\right )} + 4 \, {\left (a^{3} b^{2} - a b^{4}\right )}^{2}}}{a^{3} b^{2} - a^{2} b^{3} - a b^{4} + b^{5}}}}\right )\right )}}{{\left (a^{2} b^{3} - b^{5}\right )}^{2} {\left (a^{2} - 2 \, a b + b^{2}\right )} - {\left (a^{5} b^{2} - 2 \, a^{4} b^{3} + 2 \, a^{2} b^{5} - a b^{6}\right )} {\left | -a^{2} b^{3} + b^{5} \right |}} + \frac {2 \, {\left (2 \, B a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - A a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + B b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, B a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - A a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + B a^{2} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B a b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} + 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + a + b\right )} {\left (a^{2} b^{2} - b^{4}\right )}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 5.17, size = 2500, normalized size = 16.13 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________